package com.javaee.singleton;

public class BasicSingleton {
    private static BasicSingleton instance;

    private BasicSingleton(){}

    public static BasicSingleton getInstance() {
        if(instance == null){
            instance = new BasicSingleton();
            System.out.println("创建单例对象:" + instance);
        }
        return instance;
    }

    public static void main(String[] args){
        BasicSingleton instance1 = BasicSingleton.getInstance();
        BasicSingleton instance2 = BasicSingleton.getInstance();
        System.out.println(instance1 == instance2);
    }

}
